src/min.js
zzmq.dev@gmail.com[dev1]/mathkit[implement-min-n-function-tests] / src / min.js
@ b0bb4668
Download
Ladder Summary
- file Add a min function mirroring Math.min behavior and comprehensive tests
/**
* Returns the minimum number from the provided arguments.
* Mirrors the behavior of the built‑in Math.min:
* - Returns Infinity when called with no arguments.
* - Returns NaN if any argument is NaN.
*
* @param {...number} numbers - A list of numbers to evaluate.
* @returns {number} The smallest number, or Infinity / NaN per Math.min semantics.
*/
export function min(...numbers) {
// Delegating to the native Math.min ensures correct handling of edge cases
// such as NaN propagation and Infinity handling.
return Math.min(...numbers);
}